﻿using DevExpress.XtraEditors;
using EkStudio.com.bean.xml.reflection.JAXB;
using EkStudio.com.bean.xml.Unit;
using EkStudio.com.bean.xml.WorkFlow;
using EkStudio.com.bean.xml.WorkFlow.Node;
using EkStudio.com.common.clipboard;
using EkStudio.com.common.unit;
using EkStudio.com.ui.form;
using EkStudio.com.ui.unitbill.WorkFlow;
using EkStudio.Com.UI.Interface;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;

namespace EkStudio.com.ui.unitbill
{

    //属性回调事件
    public delegate void NodeClickHandle(object sender, WflowModuleNodeItem node);
    public partial class BillWorkFlowPanel : XtraUserControl, ProjectUnitBillInterface
    {

        private log4net.ILog logger = log4net.LogManager.GetLogger(typeof(BillWorkFlowPanel));

        private bool readOnly = false;
        private bool save = true;
        private ProjectRootPanel RootPanel = null;
        private ProjectUnitBillInterface ParentUnit = null;
        private List<ProjectUnitBillInterface> SubjectUnit = new List<ProjectUnitBillInterface>();//子面板

        private WflowModuleItem bean = null;

        private Point mouseDownPoint = Point.Empty;
        private Point userControlPoint = Point.Empty;

        private bool moving = false;

        private bool ReLoadMenu = false;

        private XtraUserControl selectNode = null;

        private List<XtraUserControl> NodeList = new List<XtraUserControl>();

        private List<LineBean> Lines = new List<LineBean>();

        private bool initLine = false;

        private FlowBENode StartUpNode = null;

        public BillWorkFlowPanel(WflowModuleItem flow, ProjectRootPanel Root, bool _readOnly)
        {
            InitializeComponent();
            bean = flow;
            RootPanel = Root;
            readOnly = _readOnly;
            InitBillModule();
        }
        private void InitBillModule()
        {

            #region 加载节点控件
            if (bean.FlowNode != null && bean.FlowNode.FlowCommandNode != null && bean.FlowNode.FlowCommandNode.Count > 0)
            {
                foreach(WflowModuleNodeItem it in bean.FlowNode.FlowCommandNode)
                {
                    if (it.NodeType == WflowUtility.NODE_TYPE_START_UP_FLOW)
                    {
                        StartUpNode = new FlowBENode(it);
                        StartUpNode.Name = it.Key;
                        StartUpNode.Dock = DockStyle.None;
                        StartUpNode.Top = it.Top;
                        StartUpNode.Left = it.Left;
                        StartUpNode.MouseDown += DropMouseDown;
                        StartUpNode.MouseMove += DropMouseMove;
                        StartUpNode.MouseUp += DropMouseUp;
                        StartUpNode.KeyDown += All_KeyDown;
                        StartUpNode.NodeClickEvent += NodeButtonClick;
                        it.Width = StartUpNode.Width;
                        it.Height = StartUpNode.Height;
                        NodeList.Add(StartUpNode);
                        NodeRootPanel.Controls.Add(StartUpNode);
                    }
                    else if (it.NodeType == WflowUtility.NODE_TYPE_FINISH_FLOW)
                    {
                        FLowEndNode end = new FLowEndNode(it);
                        end.Name = it.Key;
                        end.Dock = DockStyle.None;
                        end.Left = it.Left;
                        end.Top = it.Top;
                        end.MouseDown += DropMouseDown;
                        end.MouseMove += DropMouseMove;
                        end.MouseUp += DropMouseUp;
                        end.KeyDown += All_KeyDown;
                        end.NodeClickEvent += NodeButtonClick;
                        it.Width = end.Width;
                        it.Height = end.Height;
                        NodeList.Add(end);
                        NodeRootPanel.Controls.Add(end);
                    }else if(it.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                    {
                        FlowTaskNode task = new FlowTaskNode(it);
                        task.Name = it.Key;
                        task.Dock = DockStyle.None;
                        task.Left = it.Left;
                        task.Top = it.Top;
                        task.MouseDown += DropMouseDown;
                        task.MouseMove += DropMouseMove;
                        task.MouseUp += DropMouseUp;
                        task.KeyDown += All_KeyDown;
                        task.NodeClickEvent += NodeButtonClick;
                        it.Width = task.Width;
                        it.Height = task.Height;
                        NodeList.Add(task);
                        NodeRootPanel.Controls.Add(task);
                    }
                    else if(it.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                    {
                        FlowJudgeNode judge = new FlowJudgeNode(it);
                        judge.Name = it.Key;
                        judge.Dock = DockStyle.None;
                        judge.Left = it.Left;
                        judge.Top = it.Top;
                        judge.MouseDown += DropMouseDown;
                        judge.MouseMove += DropMouseMove;
                        judge.MouseUp += DropMouseUp;
                        judge.KeyDown += All_KeyDown;
                        judge.NodeClickEvent += NodeButtonClick;
                        it.Width = judge.Width;
                        it.Height = judge.Height;
                        NodeList.Add(judge);
                        NodeRootPanel.Controls.Add(judge);
                    }
                }
            }
            #endregion

            WFlowProperty.SelectedObject = new FlowModuleToProperty(bean);
            WFlowProperty.Enabled = !readOnly;

            ATypeRepositoryComboBox.Items.AddRange(new string[] { WflowUtility.NODE_COMMENT_APPROVE_TYPE, WflowUtility.NODE_COMMENT_TRANSITION_TYPE });
            ActivityModelRepositoryBox.Items.AddRange(WflowUtility.NODE_COMMENT_MODEL_TYPE);

            //面板注册鼠标滚轮事件
            NodeRootPanel.MouseWheel += NodeRootPanel_MouseWheel;

            InitLinePoint();
        }




        #region 接口方法


        /// <summary>
        /// 复制
        /// </summary>
        /// <param name="clazz">复制后的clazz</param>
        /// <returns></returns>
        public bool Copy(out object clazz)
        {
            bool val = false;
            clazz = null;

            return val;
        }
        public string BillKey
        {
            get
            {
                return bean.getKey();
            }
        }

        public bool isSubUnitBill
        {
            get
            {
                return false;
            }
        }

        public ProjectUnitBillInterface ParentPage
        {
            get
            {
                return ParentUnit;
            }

            set
            {
                ParentUnit = value;
            }
        }

        public bool ReadOnly
        {
            get
            {
                return readOnly;
            }

            set
            {

            }
        }

        public bool SaveStatus
        {
            get
            {
                return save;
            }

            set
            {
                save = value;
                RootPanel.SaveStatus = value;
            }
        }

        public List<ProjectUnitBillInterface> SubjectPage
        {
            get
            {
                return SubjectUnit;
            }
        }

        public void AddSubjectBill(ProjectUnitBillInterface bill)
        {
            if (!SubjectUnit.Contains(bill))
            {
                bill.ParentPage = this;
                SubjectUnit.Add(bill);
            }
        }

        

        public bool close()
        {
            bool result = true;
            if (!save || !isSubSaveStatus())
            {
                DialogResult dialog = XtraMessageBox.Show("当前数据已更改是否保存?", "提示", MessageBoxButtons.YesNoCancel);
                if (dialog == DialogResult.Yes)
                {
                    saveData(true);
                    result = true;
                }
                else if (dialog == DialogResult.No)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            if (result)
            {
                //释放模块占用
                try
                {
                    RootPanel.Http.ReleaseModule(bean.getKey(), bean.getCaption(), ProjectUtil.TYPE_BILL_WORKFLOW);
                }
                catch (Exception e)
                {
                    RootPanel.AddConsoleText("页面关闭失败", true);
                    logger.Error("页面关闭失败", e);
                }

            }

            return result;
        }

        public bool ContainSubject(ProjectUnitBillInterface bill)
        {
            return SubjectUnit.Contains(bill);
        }

        public void RemoveSubjectBill(ProjectUnitBillInterface bill)
        {
            if (SubjectUnit.Contains(bill))
            {
                bill.ParentPage = null;
                SubjectUnit.Remove(bill);
            }
        }
        #endregion
        public void saveData(bool updateParent)
        {

            if (!readOnly && (!save || !isSubSaveStatus()))
            {
                if (!isSubSaveStatus())
                {
                    //先保存子表
                    foreach (ProjectUnitBillInterface subPage in SubjectUnit)
                    {
                        subPage.saveData(false);
                    }
                }

                //恶心的winform 滚动条移动不是背板移动，而是控件上下左右移动，这时坐标会变动

                NodeRootPanel.HorizontalScroll.Value = 0;
                NodeRootPanel.VerticalScroll.Value = 0;
                InitLinePoint();
                if (NodeList.Count > 0)
                {
                    foreach(XtraUserControl xu in NodeList)
                    {
                        WflowModuleNodeItem node = xu.Tag as WflowModuleNodeItem;
                        if (node != null)
                        {
                            node.Left = xu.Left;
                            node.Top = xu.Top;
                            node.Width = xu.Width;
                            node.Height = xu.Height;
                        }
                    }
                }


                bean.Workflow.RootVersion = BeanUtil.VERSION;
                bean.Workflow.OwnerProperties.LastMender = RootPanel.UserInfo.UserName;
                bean.Workflow.OwnerProperties.LastModified = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

                JAXBContext<WflowModuleItem> jaxb = new JAXBContext<WflowModuleItem>();

                string xml = jaxb.marshal(bean, true);
                string result = RootPanel.Http.SaveXmlBean(bean.getKey(), ProjectUtil.TYPE_BILL_WORKFLOW, xml);

                XmlDocument docXml = new XmlDocument();
                try
                {
                    docXml.LoadXml(result);
                    XmlElement root = docXml.DocumentElement;
                    XmlNode node = root.SelectSingleNode("result");
                    if (node.InnerText == "0")
                    {
                        RootPanel.AddConsoleText(string.Format("保存模块[{0}]成功", bean.getCaption()), false);
                    }
                    else
                    {
                        RootPanel.AddConsoleText(string.Format("保存模块[{0}]失败", bean.getCaption()), false);
                    }
                }
                catch (Exception e)
                {
                    RootPanel.AddConsoleText(string.Format("保存模块[{0}]失败", bean.getCaption()), false);
                    logger.Error("保存失败", e);
                }
                if (ReLoadMenu) RootPanel.InitMenu();
            }
            save = true;
            if (updateParent) RootPanel.SaveStatus = true;
            WFlowProperty.Refresh();
        }

        /// <summary>
        /// 判定子页面保存状态
        /// </summary>
        /// <returns></returns>
        private bool isSubSaveStatus()
        {
            bool result = true;
            if (SubjectUnit.Count > 0)
            {
                for (int i = 0; i < SubjectUnit.Count; i++)
                {
                    if (!SubjectUnit[i].SaveStatus)
                    {
                        result = false;
                        break;
                    }
                }
            }

            return result;
        }

        #region 事件注册


        #region 控件移动事件
        /// <summary>
        /// 鼠标点击开始托动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DropMouseDown(object sender, MouseEventArgs e)
        {
            if (ReadOnly) return;
            if(e.Button == MouseButtons.Left)
            {
                XtraUserControl ct = sender as XtraUserControl;
                if (ct != null)
                {
                    
                    mouseDownPoint = Cursor.Position;
                    userControlPoint = ct.Location;
                }
            }
        }
        /// <summary>
        /// 鼠标移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DropMouseMove(object sender, MouseEventArgs e)
        {
            if (ReadOnly) return;
            if (e.Button == MouseButtons.Left)
            {
                moving = true;
                Point TMousePoint = Cursor.Position;
                int x = TMousePoint.X - mouseDownPoint.X;
                int y = TMousePoint.Y - mouseDownPoint.Y;
                Point NUserCtlPoint = new Point(userControlPoint.X + x, userControlPoint.Y + y);
                XtraUserControl ct = sender as XtraUserControl;
                if (ct != null)
                {
                    ct.Location = NUserCtlPoint;
                    WflowModuleNodeItem it = ct.Tag as WflowModuleNodeItem;
                    it.Left = ct.Left;
                    it.Top = ct.Top;
                    if (save) SaveStatus = false;
                }
            }
        }
        /// <summary>
        /// 鼠标松开
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DropMouseUp(object sender, MouseEventArgs e)
        {
            if (ReadOnly) return;
            if (moving)
            {
                mouseDownPoint = Point.Empty;
                userControlPoint = Point.Empty;
                moving = false;
                NodePropertyGrid.Refresh();
                InitLinePoint();
            }
        }

        /// <summary>
        /// 控制移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void All_KeyDown(object sender, KeyEventArgs e)
        {
            if (ReadOnly) return;
            if (e.Control)
            {
                XtraUserControl ct = sender as XtraUserControl;
                if(ct.Tag is WflowModuleNodeItem)
                {
                    WflowModuleNodeItem it = ct.Tag as WflowModuleNodeItem;
                    if (e.KeyCode == Keys.Left)//左移
                    {
                        ct.Left = ct.Left - 1;
                        it.Left = ct.Left;
                        if (save) SaveStatus = false;
                        InitLinePoint();
                    }
                    else if (e.KeyCode == Keys.Right)//右移
                    {
                        ct.Left = ct.Left + 1;
                        it.Left = ct.Left;
                        if (save) SaveStatus = false;
                        InitLinePoint();
                    }
                    else if (e.KeyCode == Keys.Up)//上移
                    {
                        ct.Top = ct.Top - 1;
                        it.Top = ct.Top;
                        if (save) SaveStatus = false;
                        InitLinePoint();
                    }
                    else if (e.KeyCode == Keys.Down)//下移
                    {
                        ct.Top = ct.Top + 1;
                        it.Top = ct.Top;
                        if (save) SaveStatus = false;
                        InitLinePoint();
                    }
                }
                
            }
        }

        #endregion

        /// <summary>
        /// 审批对象选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TargetRepositoryEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            FlowTargetModuleForm form = new FlowTargetModuleForm(RootPanel, bean, readOnly);
            if(form.ShowDialog() == DialogResult.OK)
            {
                WFlowProperty.Refresh();
                SaveStatus = false;
            }
        }

        /// <summary>
        /// 点击节点触发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="node"></param>
        private void NodeButtonClick(object sender, WflowModuleNodeItem node)
        {
            if(selectNode != sender)
            {
                selectNode = sender as XtraUserControl;
                NodePropertyGrid.SelectedObject = new NodeToProperty(node, bean);
                NodePropertyGrid.Refresh();
                NodePropertyGrid.Visible = true;
                PropertyTabControl.SelectedTabPageIndex = 0;
            }
        }
        private void NodeRootPanel_Click(object sender, EventArgs e)
        {
            selectNode = null;
            NodePropertyGrid.Visible = false;
        }
        private void NodePropertyGrid_DataSourceChanged(object sender, EventArgs e)
        {
            if (selectNode != null)
            {
                WflowModuleNodeItem node = selectNode.Tag as WflowModuleNodeItem;
                if (node != null)
                {
                    switch (node.NodeType)
                    {
                        case WflowUtility.NODE_TYPE_START_UP_FLOW://开始节点
                            row_node_javaplugin.Visible = false;
                            row_node_nextnode.Visible = true;
                            row_node_caption.Properties.ReadOnly = true;
                            row_node_key.Properties.ReadOnly = true;
                            category_node_two.Visible = false;
                            category_node_three.Visible = false;
                            category_node_four.Visible = false;
                            break;
                        case WflowUtility.NODE_TYPE_FINISH_FLOW://结束节点
                            
                            row_node_javaplugin.Visible = false;
                            row_node_nextnode.Visible = false;
                            row_node_caption.Properties.ReadOnly = true;
                            row_node_key.Properties.ReadOnly = true;
                            category_node_two.Visible = false;
                            category_node_three.Visible = false;
                            category_node_four.Visible = false;
                            break;
                        case WflowUtility.NODE_TYPE_COMMENT://审批节点
                            row_node_javaplugin.Visible = true;
                            row_node_nextnode.Visible = true;
                            row_node_caption.Properties.ReadOnly = false;
                            row_node_key.Properties.ReadOnly = false;
                            category_node_two.Visible = true;
                            category_node_three.Visible = true;
                            category_node_four.Visible = false;
                            break;
                        case WflowUtility.NODE_TYPE_CONDITION:
                            row_node_javaplugin.Visible = true;
                            row_node_nextnode.Visible = false;
                            row_node_caption.Properties.ReadOnly = false;
                            row_node_key.Properties.ReadOnly = false;
                            category_node_two.Visible = false;
                            category_node_three.Visible = false;
                            category_node_four.Visible = true;
                            break;
                        default:
                            row_node_javaplugin.Visible = true;
                            row_node_nextnode.Visible = true;
                            row_node_caption.Properties.ReadOnly = false;
                            row_node_key.Properties.ReadOnly = false;
                            category_node_two.Visible = true;
                            category_node_three.Visible = true;
                            category_node_four.Visible = true;
                            break;
                    }
                }
            }
        }
        private void NodePropertyGrid_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            if(e.Row.Properties.FieldName == "Caption")
            {
                UiNode node = selectNode as UiNode;
                node.NodeCaption = Convert.ToString(e.Value);
            }
            SaveStatus = false;
        }
        /// <summary>
        /// 下级节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NodeNextRepositoryEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (selectNode != null)
            {
                FlowNextNodeForm form = new FlowNextNodeForm(bean, selectNode.Tag as WflowModuleNodeItem, 1);
                if(form.ShowDialog() == DialogResult.OK)
                {
                    SaveStatus = false;
                    NodePropertyGrid.Refresh();
                    InitLinePoint();
                }
            }
        }
        /// <summary>
        /// 扩展代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NodeJavaNodeRepositoryEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (selectNode != null)
            {
                
                WflowModuleNodeItem node = selectNode.Tag as WflowModuleNodeItem;
                if (bean.FlowEvent == null) bean.FlowEvent = new com.bean.xml.WorkFlow.WflowModuleEventRoot();
                if (bean.FlowEvent.EventNodeList == null) bean.FlowEvent.EventNodeList = new WflowEventPluginNodeList();
                if (bean.FlowEvent.EventNodeList.Item == null) bean.FlowEvent.EventNodeList.Item = new List<WflowEventPluginNodeEvent>();
                WflowEventPluginNodeEvent java = null;
                foreach (WflowEventPluginNodeEvent ev in bean.FlowEvent.EventNodeList.Item)
                {
                    if(ev.Bind == node.Key)
                    {
                        java = ev;
                        break;
                    }
                }
                if(e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Delete)
                {
                    if (java != null)
                    {
                        if(XtraMessageBox.Show("您确认删除当前节点的扩展代码吗?","提示",MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            bean.FlowEvent.EventNodeList.Item.Remove(java);
                            SaveStatus = false;
                            NodePropertyGrid.Refresh();
                        }
                    }
                }
                else if(e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis)
                {
                    bool TSave = true;
                    if (java == null)
                    {
                        java = new WflowEventPluginNodeEvent();
                        java.Bind = node.Key;
                        java.Key = string.Format("WflowNode_{0}_Plugin", node.Key);
                        java.JavaPackage = string.Format("com.kootop.plugin.{0}", bean.getJavaPackage());
                        java.Enabled = true;
                        java.Caption = string.Format("{0}->{1}的扩展代码", bean.getCaption(), node.Caption);
                        java.Content = WflowUtility.getJavaCodeNode(java.Key, java.JavaPackage);
                        bean.FlowEvent.EventNodeList.Item.Add(java);
                        SaveStatus = false;
                        TSave = false;
                    }
                    BillFlowJavaPluginPanel panel = new BillFlowJavaPluginPanel(bean, RootPanel, this, java, TSave);
                    panel.Dock = DockStyle.Fill;
                    RootPanel.AddTabPage(java.Caption, panel, 7);
                    AddSubjectBill(panel);
                    if(!TSave)WFlowProperty.Refresh();
                }
            }
            
        }
        /// <summary>
        /// 工作流全局扩展代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void JavaRepositoryEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            WflowEventPluginModule java = null;
            if (bean.FlowEvent == null) bean.FlowEvent = new com.bean.xml.WorkFlow.WflowModuleEventRoot();
            if (bean.FlowEvent.ModuleEvent != null) java = bean.FlowEvent.ModuleEvent;
            if(e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Delete)
            {
                if (java != null)
                {
                    if (XtraMessageBox.Show("您确认删除当前工作流的扩展代码吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        bean.FlowEvent.ModuleEvent = null;
                        SaveStatus = false;
                        WFlowProperty.Refresh();
                    }
                }
            }
            else if(e.Button.Kind== DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis)
            {
                bool TSave = true;
                if (bean.FlowEvent.ModuleEvent == null)
                {
                    bean.FlowEvent.ModuleEvent = new WflowEventPluginModule();
                    java = bean.FlowEvent.ModuleEvent;
                    java.Key = string.Format("WflowModule_{0}_Plugin", bean.getKey());
                    java.JavaPackage = string.Format("com.kootop.plugin.{0}", bean.getJavaPackage());
                    java.Enabled = true;
                    java.Content = WflowUtility.getJavaCodeModule(java.Key, java.JavaPackage);
                    SaveStatus = false;
                    TSave = false;
                }
                else
                {
                    java = bean.FlowEvent.ModuleEvent;
                }
                BillFlowJavaPluginPanel panel = new BillFlowJavaPluginPanel(bean, RootPanel, this, java, TSave);
                panel.Dock = DockStyle.Fill;
                RootPanel.AddTabPage(string.Format("{0}->扩展代码",bean.getCaption()), panel, 7);
                AddSubjectBill(panel);
                if (!TSave) WFlowProperty.Refresh();
            }
        }
        /// <summary>
        /// 表达式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExpressionRepositoryEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            Object value = NodePropertyGrid.GetCellValue(NodePropertyGrid.FocusedRow, NodePropertyGrid.FocusedRecord);
            if(value is WflowExpressionElement)
            {
                WflowExpressionElement expression = value as WflowExpressionElement;
                FlowExpressionEditForm edit = new FlowExpressionEditForm(expression, readOnly);
                if(edit.ShowDialog() == DialogResult.OK)
                {
                    SaveStatus = false;
                    NodePropertyGrid.Refresh();
                }
                
            }
        }
        private void JudgeNextRepositoryEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            string name = NodePropertyGrid.FocusedRow.Properties.FieldName;
            if(name == "JudgeTrueNode")
            {
                if (selectNode != null)
                {
                    FlowNextNodeForm form = new FlowNextNodeForm(bean, selectNode.Tag as WflowModuleNodeItem, 2);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        SaveStatus = false;
                        NodePropertyGrid.Refresh();
                        InitLinePoint();
                    }
                }
            }
            else if(name == "JudgeFalseNode")
            {
                if (selectNode != null)
                {
                    FlowNextNodeForm form = new FlowNextNodeForm(bean, selectNode.Tag as WflowModuleNodeItem, 3);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        SaveStatus = false;
                        NodePropertyGrid.Refresh();
                        InitLinePoint();
                    }
                }
            }
        }
        private void WFlowProperty_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            SaveStatus = false;
        }
        /// <summary>
        /// 画线
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NodeRootPanel_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            if (Lines.Count > 0&&!initLine)
            {
                for (int i = 0; i < Lines.Count; i++)
                {
                    LineBean it = Lines[i];
                    g.DrawLine(Pens.Red, it.Begin, it.End);
                    if(it.DrawCaption) g.DrawString(it.Tag, Font, new SolidBrush(Color.Red), it.Begin);
                    if (it.Arrow != null)
                    {
                        g.DrawLine(Pens.Red, it.Arrow[0], it.Arrow[1]);
                        g.DrawLine(Pens.Red, it.Arrow[1], it.Arrow[2]);
                        g.DrawLine(Pens.Red, it.Arrow[0], it.Arrow[2]);
                    }
                }
            }
        }
        private void NodeRootPanel_Scroll(object sender, ScrollEventArgs e)
        {
            InitLinePoint();
        }

        private void NodeRootPanel_MouseWheel(object sender, MouseEventArgs e)
        {
            InitLinePoint();
        }


        /// <summary>
        /// 新建任务节点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 任务节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WflowModuleNodeItem it = new WflowModuleNodeItem();
            it.NodeType = WflowUtility.NODE_TYPE_COMMENT;
            it.Top = 20; it.Left = 200;
            it.NodeFlowActivity = new WflowNodeItemActivity();
            bean.FlowNode.addNode(it, bean);
            //添加控件
            FlowTaskNode task = new FlowTaskNode(it);
            task.Name = it.Key;
            task.Dock = DockStyle.None;
            task.Left = it.Left;
            task.Top = it.Top;
            task.MouseDown += DropMouseDown;
            task.MouseMove += DropMouseMove;
            task.MouseUp += DropMouseUp;
            task.KeyDown += All_KeyDown;
            task.NodeClickEvent += NodeButtonClick;
            it.Width = task.Width;
            it.Height = task.Height;
            NodeList.Add(task);
            NodeRootPanel.Controls.Add(task);

            selectNode = task;
            NodePropertyGrid.SelectedObject = new NodeToProperty(it, bean);
            NodePropertyGrid.Refresh();
            NodePropertyGrid.Visible = true;
            PropertyTabControl.SelectedTabPageIndex = 0;

        }

        private void 判定节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WflowModuleNodeItem it = new WflowModuleNodeItem();
            it.NodeType = WflowUtility.NODE_TYPE_CONDITION;
            it.Top = 20; it.Left = 200;
            it.NodeFlowCondition = new WflowNodeItemCondition();
            bean.FlowNode.addNode(it, bean);

            FlowJudgeNode judge = new FlowJudgeNode(it);
            judge.Name = it.Key;
            judge.Dock = DockStyle.None;
            judge.Left = it.Left;
            judge.Top = it.Top;
            judge.MouseDown += DropMouseDown;
            judge.MouseMove += DropMouseMove;
            judge.MouseUp += DropMouseUp;
            judge.KeyDown += All_KeyDown;
            judge.NodeClickEvent += NodeButtonClick;
            it.Width = judge.Width;
            it.Height = judge.Height;
            NodeList.Add(judge);
            NodeRootPanel.Controls.Add(judge);

            selectNode = judge;
            NodePropertyGrid.SelectedObject = new NodeToProperty(it, bean);
            NodePropertyGrid.Refresh();
            NodePropertyGrid.Visible = true;
            PropertyTabControl.SelectedTabPageIndex = 0;
        }
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (selectNode != null)
            {
                WflowModuleNodeItem node = selectNode.Tag as WflowModuleNodeItem;
                if(node!=null && node.NodeType != WflowUtility.NODE_TYPE_START_UP_FLOW && node.NodeType != WflowUtility.NODE_TYPE_FINISH_FLOW)
                {
                    if (XtraMessageBox.Show("您确认删除当前节点吗", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //删除所有连接到当前选择节点的节点
                        if (NodeList.Count > 0)
                        {
                            foreach(XtraUserControl xu in NodeList)
                            {
                                WflowModuleNodeItem it = xu.Tag as WflowModuleNodeItem;
                                if (it != node)
                                {
                                    if(it.NextNode == node.Key)
                                    {
                                        it.NextNode = "";
                                    }
                                    if (it.NodeFlowCondition != null)
                                    {
                                        if(it.NodeFlowCondition.TrueNode == node.Key)
                                        {
                                            it.NodeFlowCondition.TrueNode = "";
                                        }
                                        if(it.NodeFlowCondition.FalseNode == node.Key)
                                        {
                                            it.NodeFlowCondition.FalseNode = "";
                                        }
                                    }
                                }
                            }
                        }

                        NodeList.Remove(selectNode);
                        NodeRootPanel.Controls.Remove(selectNode);
                        selectNode = null;
                        bean.FlowNode.removeNode(node);
                        NodePropertyGrid.Visible = false;
                        InitLinePoint();
                        SaveStatus = false;
                    }
                }
            }
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }
        private void NTToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 全选ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }


        private void PopopMenuStrip_Opened(object sender, EventArgs e)
        {
            if (selectNode == null)
            {
                DeleteToolStripMenuItem.Enabled = false;
                CopyToolStripMenuItem.Enabled = false;
                CutToolStripMenuItem.Enabled = false;

            }
            else
            {
                DeleteToolStripMenuItem.Enabled = true;
                CopyToolStripMenuItem.Enabled = true;
                CutToolStripMenuItem.Enabled = true;
            }

            if (JClipboard.ContainData() && JClipboard.Paste()[0] is WflowModuleNodeItem)
            {
                NTToolStripMenuItem.Enabled = true;
            }
            else
            {
                NTToolStripMenuItem.Enabled = false;
            }
        }


        #endregion

        /// <summary>
        /// 通过Key查找实体控件
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        private XtraUserControl getUserControlByKey(string key)
        {
            XtraUserControl result = null;
            if (NodeList.Count > 0)
            {
                foreach(XtraUserControl it in NodeList)
                {
                    if(it.Tag is WflowModuleNodeItem)
                    {
                        WflowModuleNodeItem item = it.Tag as WflowModuleNodeItem;
                        if(item.Key == key)
                        {
                            result = it;
                            break;
                        }
                    }
                }
            }
            return result;
        }


        private void CreateLineByNode(WflowModuleNodeItem node, WflowModuleNodeItem NextNode, WflowModuleNodeLine lingCfg)
        {
            XtraUserControl NowUser = null, NextUser = null;
            NowUser = getUserControlByKey(node.Key);
            NextUser = getUserControlByKey(NextNode.Key);
            if (NextUser == null || NowUser == null) return;
            if (lingCfg != null)
            {
                int aTop = NowUser.Top, aLeft = NowUser.Left, aWidth = NowUser.Width, aHeight = NowUser.Height;
                int bTop = NextUser.Top, bLeft = NextUser.Left, bWidth = NextUser.Width, bHeight = NextUser.Height;

                //判断位置
                Point aCenter = new Point(aLeft + aWidth / 2, aTop + aHeight / 2);
                Point bCenter = new Point(bLeft + bWidth / 2, bTop + bHeight / 2);

                if ((Math.Abs(aCenter.X - bCenter.X) - aWidth / 2 - bWidth / 2) < 2 * fixedLong
                    && (Math.Abs(aCenter.Y - bCenter.Y) - aHeight / 2 - bHeight / 2) < 2 * fixedLong)
                {
                    return;
                }
                if (aCenter.Y < bCenter.Y)//第二控制在下方
                {
                    if (aCenter.X < bCenter.X)//右侧
                    {
                        if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_TOP)//顶
                        {
                            #region 开始点在上端
                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//上顶,下顶
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2 画caption
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bCenter.X, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true; else LB.DrawCaption = false;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, aTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=顶,顶", false);

                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//上，左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bLeft - fixedLong, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft - fixedLong, aTop - fixedLong);
                                LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y + 5), new Point(bLeft - 10, bCenter.Y - 5) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=顶,左", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//上，底
                            {
                                #region 结束点在下方
                                RootPanel.AddConsoleText(node.Caption + "=顶,底", false);
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//线在左边
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                    LB.End = new Point(aCenter.X + ((bCenter.X - aCenter.X) / 2), aTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aCenter.X + ((bCenter.X - aCenter.X) / 2), aTop - fixedLong);
                                    LB.End = new Point(aCenter.X + ((bCenter.X - aCenter.X) / 2), bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(aCenter.X + ((bCenter.X - aCenter.X) / 2), bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                else//线在右边
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);

                                }
                                #endregion
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//上右侧
                            {
                                //RootPanel.AddConsoleText(node.Caption + "=顶,右", false);
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4 结束线
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);

                            }
                            #endregion
                        }
                        else if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_LEFT)//左
                        {
                            #region 开始点在左端
                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//Next上
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3'
                                LB.Begin = new Point(aLeft - fixedLong, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - fixedLong);
                                if (lingCfg.Caption.Length > 0)
                                {
                                    LB.DrawCaption = true;
                                }
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4;
                                LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);

                                RootPanel.AddConsoleText(node.Caption + "=左,顶", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//Next左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=左,左", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//Next下
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4;
                                LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=左,下", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//Next右
                            {
                                RootPanel.AddConsoleText(node.Caption + "=左,右", false);
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//走上方
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft - fixedLong, aTop + aHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft - fixedLong, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4;
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                                else//走下方
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                            }

                            #endregion
                        }
                        else if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_BOTTOM)//底
                        {
                            #region 开始在底端

                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//底端到Next顶端
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bCenter.X, aTop + aHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=底,上", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//底端到Next左端
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=底,左", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//底端到Next底端
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=底,底", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//底端到Next右端
                            {
                                RootPanel.AddConsoleText(node.Caption + "=底,右", false);
                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//线走上
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                    LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                                else//线走下
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                    LB.End = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                            }

                            #endregion
                        }
                        else if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_RIGHT)//右
                        {
                            #region 开始在右端

                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//上右端，下上
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(bCenter.X, aCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(bCenter.X, aCenter.Y);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=右,上", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//上右端,下左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=右,左", false);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//上右端,下底
                            {
                                RootPanel.AddConsoleText(node.Caption + "=右,下", false);

                                #region 标题
                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//线走左
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                else//线走右
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                #endregion
                            }

                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//上右端,下右端
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y + 5), new Point(bLeft + bWidth + 10, bCenter.Y - 5) };
                                Lines.Add(LB);
                                RootPanel.AddConsoleText(node.Caption + "=右,右", false);
                            }

                            #endregion
                        }


                    }
                    else//左侧
                    {
                        if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_TOP)//顶
                        {
                            #region 从顶点开始
                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//顶，顶
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bCenter.X, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(bCenter.X, aTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//顶,左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bLeft - fixedLong, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft - fixedLong, aTop - fixedLong);
                                LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//顶，底
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);
                                #region 选择线


                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//走左线
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, aTop - fixedLong);
                                    Lines.Add(LB);


                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft - fixedLong, aTop - fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                else
                                {//右线
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4;
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5;
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                #endregion
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//顶，右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }

                            #endregion
                        }
                        else if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_LEFT)//左
                        {
                            #region 从左点开始

                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//左，顶
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(bCenter.X, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(bCenter.X, aCenter.Y);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);

                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//左,左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(bLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(bLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y + 5), new Point(bLeft - 10, bCenter.Y - 5) };
                                Lines.Add(LB);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//左,底
                            {
                                #region 线分别
                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//左线
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft, aCenter.Y);
                                    LB.End = new Point(bLeft - fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(bLeft - fixedLong, aCenter.Y);
                                    LB.End = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                else//右线
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft, aCenter.Y);
                                    LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                    Lines.Add(LB);
                                }
                                #endregion
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//左，右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }

                            #endregion
                        }
                        else if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_BOTTOM)//下
                        {
                            #region 从下点开始

                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//下，上
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bCenter.X, aTop + aHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//下，左
                            {
                                #region 线位置
                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//走上
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                    LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, aTop + aHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);
                                    LB.Begin = new Point(bLeft - fixedLong, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft - 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                                else//走下
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                    LB.End = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft - 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y + 5), new Point(bLeft - 10, bCenter.Y - 5) };
                                    Lines.Add(LB);
                                }
                                #endregion
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//下，下
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X + 5, bTop + bHeight + 10), new Point(bCenter.X - 5, bTop + bHeight + 10) };
                                Lines.Add(LB);
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//下,右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }

                            #endregion
                        }
                        else if (lingCfg.FromPoint == WflowUtility.POSTION_NODE_RIGHT)//右
                        {
                            #region 从右点开始

                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop-10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//上右,下左
                            {
                                #region 换线
                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//走上
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft - fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft - 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                    Lines.Add(LB);

                                }
                                else
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft - 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }

                                #endregion
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//上右，下底
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, bTop + bHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//上右，下右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);

                            }

                            #endregion
                        }
                    }
                }
                else//第二控件在上方
                {
                    
                    if (aCenter.X < bCenter.X)//控件在右侧
                    { 
                        if(lingCfg.FromPoint == WflowUtility.POSTION_NODE_TOP)//顶
                        {
                            #region 从顶点开始
                            if(lingCfg.ToPoint== WflowUtility.POSTION_NODE_TOP)//上，上
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, bTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//上左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//上下
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bCenter.X, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, aTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//上，右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop);
                                LB.End = new Point(aCenter.X, aTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop - fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop - fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }

                            #endregion
                        }
                        else if(lingCfg.FromPoint == WflowUtility.POSTION_NODE_LEFT)//左
                        {
                            #region 从顶点开始
                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//左，上
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft-fixedLong,aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bTop - fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft - fixedLong, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                LB.End = new Point(bCenter.X, bTop - 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//左,左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y + 5), new Point(bLeft - 10, bCenter.Y - 5) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//左,下
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                Lines.Add(LB);
                                
                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bCenter.X, bTop + bHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight),new Point(bCenter.X - 5, bTop + bHeight + 10), new Point(bCenter.X + 5, bTop + bHeight + 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//左，右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft, aCenter.Y);
                                LB.End = new Point(aLeft - fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//上线
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft - fixedLong, bTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft - fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    Lines.Add(LB);
                                    
                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                                else
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft - fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft - fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft+bWidth+fixedLong, bTop + bHeight + fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop + bHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                    LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                    Lines.Add(LB);
                                }
                            }
                            #endregion
                        }
                        else if(lingCfg.FromPoint == WflowUtility.POSTION_NODE_BOTTOM)//下
                        {
                            #region 从下端开始

                            if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)//下，顶
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                Lines.Add(LB);

                                if (lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)
                                {

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, aTop + aHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, aTop + aHeight + fixedLong);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                    Lines.Add(LB);
                                }
                                else
                                {
                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3;
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//5
                                    LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                    Lines.Add(LB);
                                }
                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT)//下左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bLeft - fixedLong, aTop + aHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft - fixedLong, aTop + aHeight + fixedLong);
                                LB.End = new Point(bLeft - fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bLeft - fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);

                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//下，下
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bCenter.X, aTop + aHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bCenter.X, bTop + bHeight + 10);
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bHeight), new Point(bCenter.X + 5, bTop + bHeight + 10), new Point(bCenter.X - 5, bTop + bHeight + 10) };
                                Lines.Add(LB);

                            }
                            else if (lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//下右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aCenter.X, aTop + aHeight);
                                LB.End = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aCenter.X, aTop + aHeight + fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, aTop + aHeight + fixedLong);
                                LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//4
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }


                            #endregion
                        }
                        else if(lingCfg.FromPoint == WflowUtility.POSTION_NODE_RIGHT)
                        {
                            #region 从右侧开始
                            if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_TOP)
                            {
                                if(lingCfg.ToPostion == WflowUtility.POSTION_NODE_LEFT)//
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                    LB.End = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(aLeft + aWidth + fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                    Lines.Add(LB);
                                }
                                else
                                {
                                    LineBean LB = new LineBean(lingCfg.Caption);//1
                                    LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//2
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                    LB.End = new Point(bLeft + bWidth + fixedLong, bTop - fixedLong);
                                    if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//3
                                    LB.Begin = new Point(bLeft + bWidth + fixedLong, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - fixedLong);
                                    Lines.Add(LB);

                                    LB = new LineBean(lingCfg.Caption);//4
                                    LB.Begin = new Point(bCenter.X, bTop - fixedLong);
                                    LB.End = new Point(bCenter.X, bTop - 10);
                                    LB.Arrow = new Point[] { new Point(bCenter.X, bTop), new Point(bCenter.X - 5, bTop - 10), new Point(bCenter.X + 5, bTop - 10) };
                                    Lines.Add(LB);
                                }
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_LEFT) //右，左
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(aLeft + aWidth + fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(aLeft + aWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft - 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft, bCenter.Y), new Point(bLeft - 10, bCenter.Y - 5), new Point(bLeft - 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_BOTTOM)//右，下
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(bCenter.X, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(bCenter.X, aCenter.Y);
                                LB.End = new Point(bCenter.X, bTop + bWidth + 10);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                LB.Arrow = new Point[] { new Point(bCenter.X, bTop + bWidth), new Point(bCenter.X - 5, bTop + bWidth + 10), new Point(bCenter.X + 5, bTop + bWidth + 10) };
                                Lines.Add(LB);
                            }
                            else if(lingCfg.ToPoint == WflowUtility.POSTION_NODE_RIGHT)//右，右
                            {
                                LineBean LB = new LineBean(lingCfg.Caption);//1
                                LB.Begin = new Point(aLeft + aWidth, aCenter.Y);
                                LB.End = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//2
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, aCenter.Y);
                                LB.End = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                if (lingCfg.Caption.Length > 0) LB.DrawCaption = true;
                                Lines.Add(LB);

                                LB = new LineBean(lingCfg.Caption);//3
                                LB.Begin = new Point(bLeft + bWidth + fixedLong, bCenter.Y);
                                LB.End = new Point(bLeft + bWidth + 10, bCenter.Y);
                                LB.Arrow = new Point[] { new Point(bLeft + bWidth, bCenter.Y), new Point(bLeft + bWidth + 10, bCenter.Y - 5), new Point(bLeft + bWidth + 10, bCenter.Y + 5) };
                                Lines.Add(LB);
                            }

                            #endregion
                        }
                    }
                    else//控件在左侧
                    {

                    }
                }
            }
        }
        /// <summary>
        /// 线数据准备
        /// </summary>
        private void InitLinePoint()
        {
            initLine = true;
            Lines.Clear();
            if(bean.FlowNode!=null&&bean.FlowNode.FlowCommandNode!=null
                && bean.FlowNode.FlowCommandNode.Count > 0)
            {
                for(int i = 0; i < bean.FlowNode.FlowCommandNode.Count; i++)
                {
                    WflowModuleNodeItem node = bean.FlowNode.FlowCommandNode[i];
                    if (node.NodeType == WflowUtility.NODE_TYPE_START_UP_FLOW
                        ||node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                    {
                        //查询下一个node
                        string next = node.NextNode;
                        if (next != "")
                        {
                            WflowModuleNodeItem NextNode = null;
                            for (int k = 0; k < bean.FlowNode.FlowCommandNode.Count; k++)
                            {
                                if(bean.FlowNode.FlowCommandNode[k].Key == next)
                                {
                                    NextNode = bean.FlowNode.FlowCommandNode[k];
                                    break;
                                }
                            }
                            if (NextNode != null)
                            {

                                WflowModuleNodeLine lingCfg = null;
                                if (node.Lines != null && node.Lines.Count > 0)
                                {
                                    foreach(WflowModuleNodeLine l in node.Lines)
                                    {
                                        if(l.Key == "1")
                                        {
                                            lingCfg = l;
                                            break;
                                        }
                                    }
                                }
                                if (lingCfg != null)
                                {

                                    CreateLineByNode(node, NextNode, lingCfg);
                                    
                                }
                            }
                        }
                    }
                    else if(node.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                    {
                        //查询下一个node
                        Console.WriteLine("判定节点:" + node.Caption);
                        string next = node.NodeFlowCondition.TrueNode;
                        if (next != "")
                        {
                            WflowModuleNodeItem NextNode = null;
                            for (int k = 0; k < bean.FlowNode.FlowCommandNode.Count; k++)
                            {
                                if (bean.FlowNode.FlowCommandNode[k].Key == next)
                                {
                                    NextNode = bean.FlowNode.FlowCommandNode[k];
                                    break;
                                }
                            }
                            if (NextNode != null)
                            {

                                WflowModuleNodeLine lingCfg = null;
                                if (node.Lines != null && node.Lines.Count > 0)
                                {
                                    foreach (WflowModuleNodeLine l in node.Lines)
                                    {
                                        if (l.Key == "2")
                                        {
                                            lingCfg = l;
                                            break;
                                        }
                                    }
                                }
                                if (lingCfg != null)
                                {
                                    Console.WriteLine("判定节点" + node.Caption);
                                    CreateLineByNode(node, NextNode, lingCfg);

                                }
                            }
                        }

                        next = node.NodeFlowCondition.FalseNode;
                        if (next != "")
                        {
                            WflowModuleNodeItem NextNode = null;
                            for (int k = 0; k < bean.FlowNode.FlowCommandNode.Count; k++)
                            {
                                if (bean.FlowNode.FlowCommandNode[k].Key == next)
                                {
                                    NextNode = bean.FlowNode.FlowCommandNode[k];
                                    break;
                                }
                            }
                            if (NextNode != null)
                            {

                                WflowModuleNodeLine lingCfg = null;
                                if (node.Lines != null && node.Lines.Count > 0)
                                {
                                    foreach (WflowModuleNodeLine l in node.Lines)
                                    {
                                        if (l.Key == "3")
                                        {
                                            lingCfg = l;
                                            break;
                                        }
                                    }
                                }
                                if (lingCfg != null)
                                {
                                    Console.WriteLine("判定节点" + node.Caption);
                                    CreateLineByNode(node, NextNode, lingCfg);

                                }
                            }
                        }
                    }
                }
            }
            initLine = false;
            NodeRootPanel.Refresh();
        }



        private const int fixedLong = 40;

        
    }

    class LineBean
    {
        private string tag = "";
        private Point begin = Point.Empty;
        private Point end = Point.Empty;

        private Point[] arrow = null;

        private bool drawCaption = false;

        private Point captionPoint = Point.Empty;

        public LineBean(string name)
        {
            tag = name;
        }

        public string Tag
        {
            get { return tag; }
            set { tag = value; }
        }

        public Point Begin
        {
            get { return begin; }
            set { begin = value; }
        }

        public Point End
        {
            get { return end; }
            set { end = value; }
        }

        public Point[] Arrow
        {
            get { return arrow; }
            set { arrow = value; }
        }

        public bool DrawCaption
        {
            get { return drawCaption; }
            set { drawCaption = value; }
        }

        public Point CaptionPoint
        {
            get { return captionPoint; }
            set { captionPoint = value; }
        }

    }

    /// <summary>
    /// 模块属性转换
    /// </summary>
    public class FlowModuleToProperty
    {
        private WflowModuleItem module = null;
        public FlowModuleToProperty(WflowModuleItem bean)
        {
            module = bean;
        }

        public string Caption
        {
            get { return module.getCaption(); }
            set { }
        }

        public string Key
        {
            get { return module.getKey(); }
            set { }
        }

        public string Target
        {
            get { return module.Workflow.FlowField != null ? string.Format("[{0}.{1}]",module.Workflow.FlowField.Caption,module.Workflow.FlowField.FieldCaption) : "[NULL]"; }
            set { }
        }

        public string AllPlugin
        {
            get { return module.FlowEvent != null && module.FlowEvent.ModuleEvent != null ? "[JavaPlugin]" : "[NULL]"; }
            set { }
        }

        public bool PrintBeforeStart
        {
            get { return module.Workflow.FlowLimit.PrintBeforeStart; }
            set { module.Workflow.FlowLimit.PrintBeforeStart = value; }
        }

        public bool PrintInprocess
        {
            get { return module.Workflow.FlowLimit.PrintInprocess; }
            set { module.Workflow.FlowLimit.PrintInprocess = value; }
        }

        public bool AttchInprocess
        {
            get { return module.Workflow.FlowLimit.AttchInprocess; }
            set { module.Workflow.FlowLimit.AttchInprocess = value; }
        }

        public string Creater
        {
            get { return module.Workflow.OwnerProperties.Creater; }
            set { }
        }

        public string Created
        {
            get { return module.Workflow.OwnerProperties.Created; }
            set { }
        }

        public string LastMender
        {
            get { return module.Workflow.OwnerProperties.LastMender; }
            set { }
        }

        public string LastModified
        {
            get { return module.Workflow.OwnerProperties.LastModified; }
            set { }
        }

    }

    

    /// <summary>
    /// 节点属性转换
    /// </summary>
    public class NodeToProperty
    {
        private WflowModuleNodeItem node = null;

        private WflowModuleItem module = null;

        public NodeToProperty(WflowModuleNodeItem it, WflowModuleItem bean)
        {
            node = it;
            module = bean;
        }

        public string Caption
        {
            get { return node.Caption; }
            set { node.Caption = value; }
        }

        public string Key
        {
            get { return node.Key; }
            set { node.Key = value; }
        }

        public string NextNode
        {
            get { return node.NextNode; }
            set { node.NextNode = value; }
        }

        public WflowEventPluginNodeEvent JavaPlugin
        {
            get
            {
                WflowEventPluginNodeEvent java = null;
                if (module.FlowEvent != null && module.FlowEvent.EventNodeList != null)
                {
                    if (module.FlowEvent.EventNodeList.Item != null)
                    {
                        foreach(WflowEventPluginNodeEvent ev in module.FlowEvent.EventNodeList.Item)
                        {
                            if(ev.Bind == node.Key)
                            {
                                java = ev;
                                break;
                            }
                        }
                    }
                }
                return java;
            }
            set
            {

            }
        }

        public bool NodeJavaEnable
        {
            get
            {
                bool enable = true;
                WflowEventPluginNodeEvent java = JavaPlugin;
                if (java != null)
                {
                    enable = java.Enabled;
                }
                return enable;
            }
            set
            {
                WflowEventPluginNodeEvent java = JavaPlugin;
                if (java != null)
                {
                    java.Enabled = value;
                }
            }
        }

        public string NodeJavaKey
        {
            get
            {
                string result = "";
                WflowEventPluginNodeEvent java = JavaPlugin;
                if (java != null)
                {
                    result = java.Key;
                }
                return result;
            }
            set
            {

            }
        }

        public int Left
        {
            get { return node.Left; }
            set { node.Left = value; }
        }

        public int Top
        {
            get { return node.Top; }
            set { node.Top = value; }
        }

        public string ActivityType
        {
            get
            {
                string result = "";
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT&&node.NodeFlowActivity != null)
                {
                    result = node.NodeFlowActivity.Type;
                }
                return result;
            }
            set
            {
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT && node.NodeFlowActivity != null)
                {
                    node.NodeFlowActivity.Type = value;
                }
            }
        }

        public string ActivityModel
        {
            get
            {
                string result = "";
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT )
                {
                    if (node.NodeFlowActivity == null) node.NodeFlowActivity = new WflowNodeItemActivity();
                    if (node.NodeFlowActivity.ExecuteProperties == null) node.NodeFlowActivity.ExecuteProperties = new WflowNodeItemAExecute();
                    result = node.NodeFlowActivity.ExecuteProperties.Model;
                }
                return result;
            }
            set
            {
                if(node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity == null) node.NodeFlowActivity = new WflowNodeItemActivity();
                    if (node.NodeFlowActivity.ExecuteProperties == null) node.NodeFlowActivity.ExecuteProperties = new WflowNodeItemAExecute();
                    node.NodeFlowActivity.ExecuteProperties.Model = value;
                }
            }
        }

        public WflowExpressionElement Performer
        {
            get
            {
                WflowExpressionElement result = null;
                if(node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity == null) node.NodeFlowActivity = new WflowNodeItemActivity();
                    if (node.NodeFlowActivity.ExecuteProperties == null) node.NodeFlowActivity.ExecuteProperties = new WflowNodeItemAExecute();
                    if (node.NodeFlowActivity.ExecuteProperties.Performer == null) node.NodeFlowActivity.ExecuteProperties.Performer = new WflowExpressionElement();
                    result = node.NodeFlowActivity.ExecuteProperties.Performer;
                }
                return result;
            }
            set
            {

            }
        }

        public bool Editable
        {
            get
            {
                bool result = false;
                if(node.NodeType == WflowUtility.NODE_TYPE_COMMENT && node.NodeFlowActivity != null && node.NodeFlowActivity.ExecuteProperties != null)
                {
                    result = node.NodeFlowActivity.ExecuteProperties.Editable;
                }
                return result;
            }
            set
            {
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT && node.NodeFlowActivity != null && node.NodeFlowActivity.ExecuteProperties != null)
                {
                    node.NodeFlowActivity.ExecuteProperties.Editable = value;
                }
            }
        }
        public bool Email
        {
            get
            {
                bool result = false;
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT && node.NodeFlowActivity != null && node.NodeFlowActivity.ExecuteProperties != null)
                {
                    result = node.NodeFlowActivity.ExecuteProperties.Email;
                }
                return result;
            }
            set
            {
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT && node.NodeFlowActivity != null && node.NodeFlowActivity.ExecuteProperties != null)
                {
                    node.NodeFlowActivity.ExecuteProperties.Email = value;
                }
            }
        }

        public bool NoticeEnable
        {
            get
            {
                bool result = false;
                if(node.NodeType== WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity != null)
                    {
                        if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                        result = node.NodeFlowActivity.FlowOutProperties.Enable;
                    }
                }
                return result;
            }
            set
            {
                if (node.NodeFlowActivity != null)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    node.NodeFlowActivity.FlowOutProperties.Enable = value;
                }
            }
        }
        /// <summary>
        /// 通知启用条件
        /// </summary>
        public WflowExpressionElement NoticeCondition
        {
            get
            {
                WflowExpressionElement result = null;
                if(node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    if (node.NodeFlowActivity.FlowOutProperties.Condition == null) node.NodeFlowActivity.FlowOutProperties.Condition = new WflowExpressionElement();
                    result = node.NodeFlowActivity.FlowOutProperties.Condition;
                }
                return result;
            }
            set
            {

            }
        }

        public bool NoticeMail
        {
            get
            {
                bool result = false;
                if(node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    if (node.NodeFlowActivity.FlowOutProperties.Message == null) node.NodeFlowActivity.FlowOutProperties.Message = new WflowMessageElement();
                    result = node.NodeFlowActivity.FlowOutProperties.Message.MailEnable;
                }
                return result;
            }
            set
            {
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    if (node.NodeFlowActivity.FlowOutProperties.Message == null) node.NodeFlowActivity.FlowOutProperties.Message = new WflowMessageElement();
                    node.NodeFlowActivity.FlowOutProperties.Message.MailEnable = value;
                }
            }
        }

        public WflowExpressionElement NoticePerformer
        {
            get
            {
                WflowExpressionElement result = null;
                if(node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    if (node.NodeFlowActivity.FlowOutProperties.Message == null) node.NodeFlowActivity.FlowOutProperties.Message = new WflowMessageElement();
                    if (node.NodeFlowActivity.FlowOutProperties.Message.Performer == null) node.NodeFlowActivity.FlowOutProperties.Message.Performer = new WflowExpressionElement();
                    result = node.NodeFlowActivity.FlowOutProperties.Message.Performer;
                }
                return result;
            }
            set
            {

            }
        }

        public WflowExpressionElement NoticeTitle
        {
            get
            {
                WflowExpressionElement result = null;
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    if (node.NodeFlowActivity.FlowOutProperties.Message == null) node.NodeFlowActivity.FlowOutProperties.Message = new WflowMessageElement();
                    if (node.NodeFlowActivity.FlowOutProperties.Message.Title == null) node.NodeFlowActivity.FlowOutProperties.Message.Title = new WflowExpressionElement();
                    result = node.NodeFlowActivity.FlowOutProperties.Message.Title;
                }
                return result;
            }
            set
            {

            }
        }

        public WflowExpressionElement NoticeContent
        {
            get
            {
                WflowExpressionElement result = null;
                if (node.NodeType == WflowUtility.NODE_TYPE_COMMENT)
                {
                    if (node.NodeFlowActivity.FlowOutProperties == null) node.NodeFlowActivity.FlowOutProperties = new WflowNodeItemAOutBand();
                    if (node.NodeFlowActivity.FlowOutProperties.Message == null) node.NodeFlowActivity.FlowOutProperties.Message = new WflowMessageElement();
                    if (node.NodeFlowActivity.FlowOutProperties.Message.Content == null) node.NodeFlowActivity.FlowOutProperties.Message.Content = new WflowExpressionElement();
                    result = node.NodeFlowActivity.FlowOutProperties.Message.Content;
                }
                return result;
            }
            set
            {

            }
        }

        public string JudgeTrueNode
        {
            get
            {
                string result = "";
                if(node.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                {
                    if (node.NodeFlowCondition == null) node.NodeFlowCondition = new WflowNodeItemCondition();
                    if (node.NodeFlowCondition.Condition == null) node.NodeFlowCondition.Condition = new WflowExpressionElement();
                    result = node.NodeFlowCondition.TrueNode;
                }
                return result;
            }
            set
            {
                if(node.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                {
                    if (node.NodeFlowCondition == null) node.NodeFlowCondition = new WflowNodeItemCondition();
                    if (node.NodeFlowCondition.Condition == null) node.NodeFlowCondition.Condition = new WflowExpressionElement();
                    node.NodeFlowCondition.TrueNode = value ;
                }
            }
        }

        public string JudgeFalseNode
        {
            get
            {
                string result = "";
                if (node.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                {
                    if (node.NodeFlowCondition == null) node.NodeFlowCondition = new WflowNodeItemCondition();
                    if (node.NodeFlowCondition.Condition == null) node.NodeFlowCondition.Condition = new WflowExpressionElement();
                    result = node.NodeFlowCondition.FalseNode;
                }
                return result;
            }
            set
            {
                if (node.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                {
                    if (node.NodeFlowCondition == null) node.NodeFlowCondition = new WflowNodeItemCondition();
                    if (node.NodeFlowCondition.Condition == null) node.NodeFlowCondition.Condition = new WflowExpressionElement();
                    node.NodeFlowCondition.FalseNode = value;
                }
            }
        }

        public WflowExpressionElement JudgeCondition
        {
            get
            {
                WflowExpressionElement result = null;
                if(node.NodeType == WflowUtility.NODE_TYPE_CONDITION)
                {
                    if (node.NodeFlowCondition == null) node.NodeFlowCondition = new WflowNodeItemCondition();
                    if (node.NodeFlowCondition.Condition == null) node.NodeFlowCondition.Condition = new WflowExpressionElement();
                    result = node.NodeFlowCondition.Condition;
                }
                return result;
            }
            set
            {

            }
        }

    }

}
